import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginView from '@/views/LoginView.vue'
import AdminView from '@/views/AdminView.vue'
import AdminAlumnus from '@/components/AdminAlumnus.vue'
import AdminAct from '@/components/AdminAct.vue'
import ActId from '@/components/ActId.vue'
import HomeMain from '@/components/HomeMain.vue'
import UserChat from '@/components/UserChat.vue'
import AlumniMap from '@/components/AlumniMap.vue'
import UserInfo from '@/components/UserInfo.vue'



Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    children:[
      {
        path: '/activity/:id',
        name: 'ActId',
        component: ActId
      },
      {
        path: '',
        name: 'main',
        component: HomeMain
      },
      {
        path: '/userChat',
        name: 'UserChat',
        component: UserChat
      },
      {
        path: '/alumniMap',
        name: 'AlumniMap',
        component: AlumniMap
      },
      {
        path: '/alumniInfo/:username',
        name: 'UserInfo',
        component: UserInfo
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/admin',
    name: 'admin',
    component: AdminView,
    children: [
      {
        path: '/admin/alumnus',
        name: 'alumnus',
        component: AdminAlumnus
      },
      {
        path: '/admin/act',
        name: 'act',
        component: AdminAct
      },
    ]
  },
  
]

const router = new VueRouter({
  routes
})

export default router
